<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <script>
        /**
         * 获取指定键后面的那个键值对
         * @param {Map} map - 要遍历的 Map 对象
         * @param {any} key - 要查找的键
         * @returns {Array|null} 返回指定键后面的那个键值对，如果找不到则返回 null
         */
        function getNextEntry(map, key) {
            let found = false;

            for (let [k, v] of map) {
                if (found) {
                    return [k, v];
                }
                if (k === key) {
                    found = true;
                }
            }

            return [null, null];
        }

        // 示例用法
        const myMap = new Map([
            ['key1', 'value1'],
            ['key2', 'value2'],
            ['key3', 'value3'],
            ['key4', 'value4']
        ]);

        const key = 'key2';
        const [k,v] = getNextEntry(myMap, key);

        console.log(k,v); // ['key3', 'value3']
    </script>
</body>
</html>